package com.leetcode.greedy;

/**
 * @author Dennis Li
 * @date 2020/7/23 21:18
 */
public class IsSubsequnce_392 {

    public boolean isSubsequence(String s, String t) {
        if (s.length() == 0) return true;
        int index = -1;
        for (int i = 0; i < s.length(); i++) {
            index = t.indexOf(s.charAt(i), index + 1);
            if (index == -1) return false;
        }
        return true;
    }


    public static void main(String[] args) {
        String s1 = "aaaaaa";
        String s2 = "bbaaaa";
        int index = 0;
        for (int i = 0; i < s1.length(); i++) {
            char c = s1.charAt(i);
            index = s2.indexOf(c, index);
            System.out.print(index + " ");
        }
    }
}
